# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

from cms.sitemaps import CMSSitemap
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls import patterns
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import TemplateView
from django.views.decorators.cache import cache_page
from account.views import youhui, detail
from book.views import book_youhui, book_detail

admin.autodiscover()

urlpatterns = [
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': {'cmspages': CMSSitemap}}),
    url(r'^select2/', include('django_select2.urls')),
]

# i18n_patterns

urlpatterns += patterns('',
    url(r'^account/dashboard/$', 'account.views.dashboard', name='dashboard'),
    url(r'^account/logout/$', 'account.views.logout', name='logout'),
    url(r'^account/signin/$', 'account.views.signin', name='signin'),
    url(r'^account/bind/$', 'account.views.bind', name='bind'),
    url(r'^account/sendsms/$', 'account.views.sendsms',name='sendsms'),
    # # url(r'^account/demo/$', TemplateView.as_view(template_name='weui/weixin-jssdk.html')),
    url(r'^account/weixin-jssdk-demo/$','account.weixin.jssdk_demo', name='jssdk_demo'),
    # url(r'^account/sendCode/$', 'account.views.generate_and_send_code',name='generate_rand_code'),
    url(r'^account/wechat/callback/$','account.views.callback',name='callback'),
    # url(r'^account/wechat/portal/$','account.wechat.portal',name='portal'),
    url(r'^account/wechat/getsignature/$','account.weixin.get_signature',name='getsignature'),
    url(r'^account/wechat/api/$','account.weixin.api',name='api'),
    url(r'^cps/naichajia/callback/$','account.views.jd_callback',name='jd_callback'),
    url(r'^promotion/$','account.views.get_jd_promotion_code',name='get_jd_promotion_code'),
    url(r'^account/save/followers/$','account.weixin.save_followers', name='save_followers'),
    url(r'^account/my/keywords/$', 'account.views.my_keywords', name='my_keywords'),
    url(r'^account/keywords/post/$', 'account.views.post_keywords', name='post_keywords'),
    url(r'^account/broadcast/([a-zA-Z0-9\-\._\/]+?)/$', 'account.views.broadcast', name='broadcast'),
    url(r'^account/$', 'account.views.dashboard'),
    url(r'^book/youhui/detail/([\s\S]*?)/$', 'book.views.book_detail'),
    url(r'^book/youhui/$', 'book.views.book_youhui'),
    # url(r'^book/youhui/([\s\S]*?)/$', cache_page(60 * 60 * 12)(book_detail)),
    # url(r'^book/youhui/$', cache_page(60 * 60)(book_youhui)),
    # url(r'^youhui/$', cache_page(60 * 2)(youhui)),
    url(r'^youhui/mall/(?P<mall>[a-zA-Z0-9\-\._\/]+?)/$', 'account.views.youhui'),
    # url(r'^youhui/category/(?P<category>[a-zA-Z0-9\-\._\/]+?)/$', cache_page(60 * 2)(youhui)),)
    url(r'^youhui/category/(?P<category>[a-zA-Z0-9\-\._\/]+?)/$', 'account.views.youhui'),
    # url(r'^youhui/channel/(?P<channel>[a-zA-Z0-9\-\._\/]+?)/$', cache_page(60 * 2)(youhui)),)
    url(r'^youhui/channel/(?P<channel>[a-zA-Z0-9\-\._\/]+?)/$', 'account.views.youhui'),
    # url(r'^youhui/detail/([\s\S]*?)/$', cache_page(60 * 2)(detail)),
    url(r'^youhui/detail/([\s\S]*?)/$', 'account.views.detail'),
    url(r'^youhui/$', 'account.views.youhui'),
    # url(r'^youhui/mall/(?P<mall>[a-zA-Z0-9\-\._\/]+?)/$', cache_page(60 * 2)(youhui)),
    url(r'^weixin/person/center/$', 'account.views.weixin_person_center', name='weixin_person_center'),
    url(r'^weixin/share/post/$', 'account.views.share_post_view', name='share_post_view'),
    url(r'^job/manual/update/$', 'account.views.manual_update_inactive'),
    url(r'^job/manual/delete/$', 'account.views.manual_delete_inactive'),
    url(r'^job/check/proxy/$', 'account.views.check_proxy'),
    url(r'^job/star/fetch/$', 'account.views.crawl_sina_stars'),
    url(r'^test/pinyin/$', 'testapp.views.display_pinyin'),
    url(r'^invest/import/$', 'invest.views.import_chinese_word'),
    url(r'^invest/douban/$', 'invest.views.import_douban_books'),
    url(r'^book/wechat/subscription/$','book.wechat.subscription',name='book_subscription'),
    url(r'^book/wechat/service/$','book.wechat.service',name='book_service'),
    url(r'^redirect_url/([\s\S]*?)/$', 'account.views.redirect_url',name='redirect_url'),
    url(r'^wxredirect/([\s\S]*?)/$', 'account.views.wx_redirect',name='wx_redirect'),
    url(r'MP_verify_qC75MURymOJrMZdz.txt', TemplateView.as_view(template_name='weixin/MP_verify_qC75MURymOJrMZdz.txt')), # 每周精选购
    url(r'MP_verify_qlGHvy8DPTBkiK5b.txt', TemplateView.as_view(template_name='book/MP_verify_qlGHvy8DPTBkiK5b.txt')), # 分级阅读书目
    url(r'MP_verify_WMY8LAvx951FuQ38.txt', TemplateView.as_view(template_name='book/MP_verify_WMY8LAvx951FuQ38.txt')), # 儿童分级阅读书目
    url(r'jd_root.txt', TemplateView.as_view(template_name='jd/jd_root.txt')),
    url(r'root.txt', TemplateView.as_view(template_name='taobao/root.txt')),

    url(r'^admin/', include(admin.site.urls)),  # NOQA
    url(r'^enroll/', include('djangocms_forms.urls')),
    url(r'^', include('cms.urls')),
)

# This is only needed when using runserver.
if settings.DEBUG:
    urlpatterns = [
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        ] + staticfiles_urlpatterns() + urlpatterns
